using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class pages_MasterPage : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        User user = Session["user"] as User;
        if (user == null) user=new User();
        Session["user"]=user;
        if (user.Id>0)
        {
            lnkLogin.Visible = false;
            lnkLogout.Visible = true;
            lnkRegister.Visible = false;
            lblUser.Visible = true;
            lblUser.Text = user.UserName + " &raquo";
            lblUser.PostBackUrl = "../admin/Default.aspx";
        }
        else
        {
            lnkLogout.Visible = false;
            lnkLogin.Visible = true;
            lnkRegister.Visible = true;
            lblUser.Visible = false;
        }
        LoadData();
    }
    public void LoadData()
    {    
        SpotCategoryDAO daoSpotCate = new SpotCategoryDAO();
        ArticleDAO daoArticle = new ArticleDAO();        
        rptSpotCate.DataSource=daoSpotCate.GetAllSpotCategories("%");
        int total=0;
        rptArticle.DataSource = daoArticle.GetAllArticles(10, 1,ref total,ServiceObject.Published);
        rptSpotCate.DataBind();
        rptArticle.DataBind();
        LoadSlideShow();
    }
    /// <summary>
    /// Load slide show on left sidebar
    /// </summary>
    public void LoadSlideShow()
    {
        DataSet ds = new DataSet();
        ds.ReadXml(Server.MapPath("../SlideShowConfig.xml"));
        rptSlideshow.DataSource = ds;
        rptSlideshow.DataBind();
    }
}
